<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>文章添加</title>
	<meta name="decorator" content="default"/>
    <script type="text/javascript" charset="utf-8" src="/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/ueditor/ueditor.all.min.js"> </script>
    <script type="text/javascript" charset="utf-8" src="/ueditor/lang/zh-cn/zh-cn.js"></script>
</head>
<body>
<div class="main-content">
    <tags:breadcrumb menuId="文章添加" />
    <div class="page-content">
        <form:form id="inputForm" modelAttribute="article" action="${ctx}/cms/article/save" method="post" class="form-horizontal">
            <form:hidden path="id"/>
            <div class="form-group">
                <label class="col-sm-2 no-padding-right control-label"><span class="important">*</span>归属栏目:</label>
                <div class="col-md-4">
                    <tags:treeselect id="category" name="category.id" value="${article.category.id}" labelName="category.name" labelValue="${article.category.name}"
                             title="所属栏目" url="/cms/category/treeData?type=1" selectIds="${article.category.id}" cssClass="required col-md-10"/>
                </div>
                <div class="col-md-1">
                    <input id="url" type="checkbox" style="margin-top: 5px;" onclick="if(this.checked){$('#linkBody').show()}else{$('#linkBody').hide()}$('#link').val()">
                    <label class="control-label" for="url">外部链接</label>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-sm-2 no-padding-right control-label"><span class="important">*</span>中文标题:</label>
                <div class="col-sm-4">
                    <form:input path="title" htmlEscape="false" maxlength="200" class="col-sm-12 required"/>
                </div>
                <label class="col-sm-1 no-padding-right control-label"><span class="important">*</span>英文标题:</label>
                <div class="col-sm-3">
                    <form:input path="entitle" htmlEscape="false" maxlength="200" class="col-sm-12 required"/>
                </div>
                <div class="col-md-2">
                    <label class="control-label">颜色:</label>
                    <form:select path="color" class="input-mini">
                        <form:option value="" label="默认"/>
                        <form:options items="${fns:getDictList('color')}" itemLabel="label" itemValue="value" htmlEscape="false" />
                    </form:select>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-sm-2 no-padding-right control-label"><span class="important">*</span>中文关键字:</label>
                <div class="col-sm-4">
                    <form:input path="keywords" htmlEscape="false" maxlength="200" class="col-md-12 required" placeholder="多个关键字，用空格分隔"/>
                </div>
                <label class="col-sm-1 no-padding-right control-label"><span class="important">*</span>英文关键字:</label>
                <div class="col-sm-5">
                    <form:input path="enkeywords" htmlEscape="false" maxlength="200" class="col-md-12 required" placeholder="多个关键字，用空格分隔"/>
                </div>
            </div><hr>
            <div style="display: none;">
                <div class="form-group" >
                    <label class="col-sm-2 no-padding-right control-label">外部链接:</label>
                    <div class="col-sm-10">
                        <form:input path="link" htmlEscape="false" maxlength="200" class="col-sm-6"/>
                    </div>
                </div><hr>
            </div>
            <div class="form-group">
                <label class="col-sm-2 no-padding-right control-label">权重:</label>
                <div class="col-sm-3">
                    <form:input path="weight" htmlEscape="false" maxlength="200" class="col-md-10 number"/>
                    <span style="margin-left: 10px;">
                        <input id="weightTop" type="checkbox" onclick="$('#weight').val(this.checked?'999':'0')"><label for="weightTop">置顶</label>
                    </span>
                </div>
                <label class="col-sm-2 no-padding-right control-label">过期时间:</label>
                <div class="col-sm-5">
                    <input id="weightDate" name="weightDate" type="text" readonly="readonly" maxlength="20" class="col-md-3 Wdate"
                           value="<fmt:formatDate value="${article.weightDate}" pattern="yyyy-MM-dd"/>"
                           onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});"/>
                    <span class="help-inline">数值越大排序越靠前，过期时间可为空，过期后取消置顶。</span>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-sm-2 no-padding-right control-label"><span class="important">*</span>中文摘要:</label>
                <div class="col-sm-4">
                    <form:textarea path="description" htmlEscape="false" rows="4" maxlength="200" class="col-md-12 required"/>
                </div>
                <label class="col-sm-1 no-padding-right control-label"><span class="important">*</span>英文摘要:</label>
                <div class="col-sm-5">
                    <form:textarea path="endescription" htmlEscape="false" rows="4" maxlength="200" class="col-md-10 required"/>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-sm-2 no-padding-right control-label"><span class="important">*</span>中文正文:</label>
                <div class="col-sm-8">
                    <script id="editor" name="articleData.content" type="text/plain" style="height:500px;width:900px;"></script>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-sm-2 no-padding-right control-label"><span class="important">*</span>英文正文:</label>
                <div class="col-sm-8">
                    <script id="eneditor" name="articleData.encontent" type="text/plain" style="height:500px;width:900px;"></script>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-sm-2 no-padding-right control-label">缩略图:</label>
                <div class="col-sm-3">
                    <input type="text" id="image" name="image" value="${article.image}" class="col-md-12"/>
                </div>
                <label class="col-sm-1 no-padding-right control-label">中文来源:</label>
                <div class="col-sm-2">
                    <input type="text" id="copyfrom" name="articleData.copyfrom" value="${article.articleData.copyfrom}" />
                </div>
                <label class="col-sm-1 no-padding-right control-label">英文来源:</label>
                <div class="col-sm-2">
                    <input type="text" id="enCopyfrom" name="articleData.enCopyfrom" value="${article.articleData.enCopyfrom}" class="col-md-12" />
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-sm-2 no-padding-right control-label">相关文章:</label>
                <div class="col-sm-8">
                    <input type="text" id="relation" name="articleData.relation" value="${article.articleData.relation}" class="col-md-12"/>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-sm-2 no-padding-right control-label"><span class="important">*</span>是否允许评论:</label>
                <div class="col-sm-3">
                    <input type="text" id="allowComment" name="articleData.allowComment" value="${article.articleData.allowComment}" class="required"/>
                </div>
                <label class="col-sm-2 no-padding-right control-label"><span class="important">*</span>推荐位:</label>
                <div class="col-sm-3">
                    <input type="text" id="posid" name="posid" value="${article.posid}" class="required"/>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-sm-2 no-padding-right control-label">发布时间:</label>
                <div class="col-sm-3">
                    <input id="createDate" name="createDate" type="text" readonly="readonly" maxlength="20" class="col-md-8 Wdate"
                           value="<fmt:formatDate value="${article.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
                           onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
                </div>
                <label class="col-sm-2 no-padding-right control-label">发布状态:</label>
                <div class="col-sm-4">
                    <div style="position: absolute;top: 5px;">
                        <form:radiobuttons path="delFlag" items="${fns:getDictList('cms_del_flag')}" itemLabel="label" itemValue="value" htmlEscape="false" class="required"/>
                    </div>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-sm-2 no-padding-right control-label">自定义内容视图:</label>
                <div class="col-sm-3">
                    <form:select path="customContentView" class="input-medium">
                        <form:option value="" label="默认视图"/>
                        <form:options items="${contentViewList}" htmlEscape="false"/>
                    </form:select>
                    <span class="help-inline" style="position: absolute;top: -5px;">自定义内容视图名称必须以"${article_DEFAULT_TEMPLATE}"开始</span>
                </div>
                <label class="col-sm-2 no-padding-right control-label">自定义视图参数:</label>
                <div class="col-sm-5">
                    <form:input path="viewConfig" htmlEscape="true"/>
                    <span class="help-inline">视图参数例如: {count:2, title_show:"yes"}</span>
                </div>
            </div><hr>
            <div class="form-actions">
                <div class="col-md-offset-4">
                    <shiro:hasPermission name="cms:article:edit"><input id="btnSubmit" class="btn btn-primary" type="button" value="保 存"/>&nbsp;</shiro:hasPermission>
                    <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
                </div>
            </div>
        </form:form>
    </div>
</div>
    <script type="text/javascript">
        $(document).ready(function() {
            var ue = UE.getEditor('editor',{
                toolbars: [
                    [
                        'anchor', //锚点
                        'undo', //撤销
                        'redo', //重做
                        'bold', //加粗
                        'indent', //首行缩进
                        'italic', //斜体
                        'underline', //下划线
                        'strikethrough', //删除线
                        'subscript', //下标
                        'fontborder', //字符边框
                        'superscript', //上标
                        'formatmatch', //格式刷
                        'source', //源代码
                        'blockquote', //引用
                        'pasteplain', //纯文本粘贴模式
                        'selectall', //全选
                        'preview', //预览
                        'horizontal', //分隔线
                        'removeformat', //清除格式
                        'time', //时间
                        'date', //日期
                        'unlink', //取消链接
                        'insertrow', //前插入行
                        'insertcol', //前插入列
                        'mergeright', //右合并单元格
                        'mergedown', //下合并单元格
                        'deleterow', //删除行
                        'deletecol', //删除列
                        'splittorows', //拆分成行
                        'splittocols', //拆分成列
                        'splittocells', //完全拆分单元格
                        'deletecaption', //删除表格标题
                        'inserttitle', //插入标题
                        'mergecells', //合并多个单元格
                        'deletetable', //删除表格
                        'cleardoc', //清空文档
                        'insertparagraphbeforetable', //"表格前插入行"
                        'fontfamily', //字体
                        'fontsize', //字号
                        'paragraph', //段落格式
                        'simpleupload', //单图上传
                        'insertimage', //多图上传
                        'edittable', //表格属性
                        'edittd', //单元格属性
                        'link', //超链接
                        'emotion', //表情
                        'spechars', //特殊字符
                        'searchreplace', //查询替换
                        'map', //Baidu地图
                        'insertvideo', //视频
                        'help', //帮助
                        'justifyleft', //居左对齐
                        'justifyright', //居右对齐
                        'justifycenter', //居中对齐
                        'justifyjustify', //两端对齐
                        'forecolor', //字体颜色
                        'backcolor', //背景色
                        'insertorderedlist', //有序列表
                        'insertunorderedlist', //无序列表
                        'fullscreen', //全屏
                        'directionalityltr', //从左向右输入
                        'directionalityrtl', //从右向左输入
                        'rowspacingtop', //段前距
                        'rowspacingbottom', //段后距
                        'pagebreak', //分页
                        'insertframe', //插入Iframe
                        'imagenone', //默认
                        'imageleft', //左浮动
                        'imageright', //右浮动
                        'attachment', //附件
                        'imagecenter', //居中
                        'wordimage', //图片转存
                        'lineheight', //行间距
                        'edittip ', //编辑提示
                        'customstyle', //自定义标题
                        'autotypeset', //自动排版
                        'touppercase', //字母大写
                        'tolowercase', //字母小写
                        'background', //背景
                        'template', //模板
                        'scrawl', //涂鸦
                        'music', //音乐
                        'inserttable', //插入表格
                        'drafts', // 从草稿箱加载
                        'charts', // 图表
                    ]
                ],
                initialContent:'${article.articleData.content}'
            });
            var enue = UE.getEditor('eneditor',{
                toolbars: [
                    [
                        'anchor', //锚点
                        'undo', //撤销
                        'redo', //重做
                        'bold', //加粗
                        'indent', //首行缩进
                        'italic', //斜体
                        'underline', //下划线
                        'strikethrough', //删除线
                        'subscript', //下标
                        'fontborder', //字符边框
                        'superscript', //上标
                        'formatmatch', //格式刷
                        'source', //源代码
                        'blockquote', //引用
                        'pasteplain', //纯文本粘贴模式
                        'selectall', //全选
                        'preview', //预览
                        'horizontal', //分隔线
                        'removeformat', //清除格式
                        'time', //时间
                        'date', //日期
                        'unlink', //取消链接
                        'insertrow', //前插入行
                        'insertcol', //前插入列
                        'mergeright', //右合并单元格
                        'mergedown', //下合并单元格
                        'deleterow', //删除行
                        'deletecol', //删除列
                        'splittorows', //拆分成行
                        'splittocols', //拆分成列
                        'splittocells', //完全拆分单元格
                        'deletecaption', //删除表格标题
                        'inserttitle', //插入标题
                        'mergecells', //合并多个单元格
                        'deletetable', //删除表格
                        'cleardoc', //清空文档
                        'insertparagraphbeforetable', //"表格前插入行"
                        'fontfamily', //字体
                        'fontsize', //字号
                        'paragraph', //段落格式
                        'simpleupload', //单图上传
                        'insertimage', //多图上传
                        'edittable', //表格属性
                        'edittd', //单元格属性
                        'link', //超链接
                        'emotion', //表情
                        'spechars', //特殊字符
                        'searchreplace', //查询替换
                        'map', //Baidu地图
                        'insertvideo', //视频
                        'help', //帮助
                        'justifyleft', //居左对齐
                        'justifyright', //居右对齐
                        'justifycenter', //居中对齐
                        'justifyjustify', //两端对齐
                        'forecolor', //字体颜色
                        'backcolor', //背景色
                        'insertorderedlist', //有序列表
                        'insertunorderedlist', //无序列表
                        'fullscreen', //全屏
                        'directionalityltr', //从左向右输入
                        'directionalityrtl', //从右向左输入
                        'rowspacingtop', //段前距
                        'rowspacingbottom', //段后距
                        'pagebreak', //分页
                        'insertframe', //插入Iframe
                        'imagenone', //默认
                        'imageleft', //左浮动
                        'imageright', //右浮动
                        'attachment', //附件
                        'imagecenter', //居中
                        'wordimage', //图片转存
                        'lineheight', //行间距
                        'edittip ', //编辑提示
                        'customstyle', //自定义标题
                        'autotypeset', //自动排版
                        'touppercase', //字母大写
                        'tolowercase', //字母小写
                        'background', //背景
                        'template', //模板
                        'scrawl', //涂鸦
                        'music', //音乐
                        'inserttable', //插入表格
                        'drafts', // 从草稿箱加载
                        'charts', // 图表
                    ]
                ],
                initialContent:'${article.articleData.encontent}'
            });
            $("#name").focus();
            $("#btnSubmit").click(function(){
                if($("#inputForm").valid()){
                    $.post("${ctx}/cms/article/save",$("#inputForm").serialize(),function(data){
                        if(data.success){
                            showNote("success", function () {
                                window.location.href = "${ctx}/cms/article/list";
                            }, data.msg);
                        }else {
                            showNote("error",function(){return false;},data.msg);
                        }
                    });
                }else{
                    showNote("error",function(){return false;},"输入有误，请正确输入数据","center");
                }
            });
        });
    </script>
</body>
</html>
